package com.ck.GUI;

import com.blacamdk.ChatNetModule.ClientMain;
import com.blacamdk.ChatNetModule.syncWithServer;

import javax.swing.*;

import ch.randelshofer.quaqua.util.Methods;

/**
 * Main
 *
 * @author BlacAmDK
 * @date 16-12-21
 */
public class Main {
    public static ChatFrame cf = null;
    public static void main(String[] args) {
//        设置Swing皮肤
        System.setProperty("Quaqua.tabLayoutPolicy", "wrap");
        if (!System.getProperty("os.name").toLowerCase().startsWith("mac")) {
            try {
                Methods.invokeStatic(JFrame.class,
                        "setDefaultLookAndFeelDecorated", Boolean.TYPE,
                        Boolean.TRUE);
                Methods.invokeStatic(JDialog.class,
                        "setDefaultLookAndFeelDecorated", Boolean.TYPE,
                        Boolean.TRUE);
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
        }
        try {
            UIManager.setLookAndFeel("ch.randelshofer.quaqua.QuaquaLookAndFeel");
        } catch (Exception ignored) { }
        Thread loginframe = new Thread(new LoginFrame());
        try {
            loginframe.start();
            loginframe.join();
        } catch (InterruptedException ignored) { }
       // 新窗口显示
        cf = new ChatFrame(LoginFrame.username);
        System.gc();
        //启动监听服务器消息的线程
        ClientMain.updateUserList();
        new Thread(new syncWithServer()).start();
    }
}
